<?php

require_once("../config/tencent_config.php");
require_once("utils.php");

function tencent_get_username($openid, $access_token)
{
	$get_user_info = "https://graph.qq.com/user/get_user_info?"
		. "access_token=" . $access_token
		. "&oauth_consumer_key=" . APP_ID
		. "&openid=" . $openid
		. "&format=json";
	
	$info = get_url_contents($get_user_info);
	$arr = json_decode($info, true);
	
	return $arr["nickname"];
}

function tencent_add_weibo($openid, $access_token, $content)
{
	$url  = "https://graph.qq.com/t/add_t";
	$data = "access_token=".$access_token
		."&oauth_consumer_key=" . APP_ID
		."&openid=".$openid
		."&format=json&syncflag=1"
		."&content=".urlencode($content);
	
	$ret = do_post($url, $data); 
	return $ret;
}
?>